using Microsoft.AspNetCore.Mvc;
using ZR.Admin.WebApi.Filters;
using ZR.Model.Dto.Business.ProductionControl;
using ZR.Model.Models.ProductionControl;
using ZR.Service.IService.ProductionControl;

//创建时间：2024-10-09
namespace ZR.Admin.WebApi.Controllers
{
    /// <summary>
    /// 故障信息点位详情
    /// </summary>
    [Verify]
    [Route("formula/faultsubclassdetails")]
    [ApiExplorerSettings(GroupName = "business")]
    public class FaultSubclassDetailsController : BaseController
    {
        /// <summary>
        /// 故障信息点位详情接口
        /// </summary>
        private readonly IFaultSubclassDetailsService _FaultSubclassDetailsService;

        public FaultSubclassDetailsController(IFaultSubclassDetailsService FaultSubclassDetailsService)
        {
            _FaultSubclassDetailsService = FaultSubclassDetailsService;
        }

        /// <summary>
        /// 查询故障信息点位详情列表
        /// </summary>
        /// <param name="parm"></param>
        /// <returns></returns>
        [HttpGet("list")]
        [ActionPermissionFilter(Permission = "formula:faultsubclassdetails:list")]
        public IActionResult QueryFaultSubclassDetails([FromQuery] FaultSubclassDetailsQueryDto parm)
        {
            var response = _FaultSubclassDetailsService.GetList(parm);
            return SUCCESS(response);
        }


        /// <summary>
        /// 查询故障信息点位详情详情
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        [HttpGet("{Id}")]
        [ActionPermissionFilter(Permission = "formula:faultsubclassdetails:query")]
        public IActionResult GetFaultSubclassDetails(int Id)
        {
            var response = _FaultSubclassDetailsService.GetInfo(Id);
            
            var info = response.Adapt<FaultSubclassDetailsDto>();
            return SUCCESS(info);
        }

        /// <summary>
        /// 添加故障信息点位详情
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        [ActionPermissionFilter(Permission = "formula:faultsubclassdetails:add")]
        [Log(Title = "故障信息点位详情", BusinessType = BusinessType.INSERT)]
        public IActionResult AddFaultSubclassDetails([FromBody] FaultSubclassDetailsDto parm)
        {
            var modal = parm.Adapt<FaultSubclassDetails>().ToCreate(HttpContext);

            var response = _FaultSubclassDetailsService.AddFaultSubclassDetails(modal);

            return SUCCESS(response);
        }

        /// <summary>
        /// 更新故障信息点位详情
        /// </summary>
        /// <returns></returns>
        [HttpPut]
        [ActionPermissionFilter(Permission = "formula:faultsubclassdetails:edit")]
        [Log(Title = "故障信息点位详情", BusinessType = BusinessType.UPDATE)]
        public IActionResult UpdateFaultSubclassDetails([FromBody] FaultSubclassDetailsDto parm)
        {
            var modal = parm.Adapt<FaultSubclassDetails>().ToUpdate(HttpContext);
            var response = _FaultSubclassDetailsService.UpdateFaultSubclassDetails(modal);

            return ToResponse(response);
        }

        /// <summary>
        /// 删除故障信息点位详情
        /// </summary>
        /// <returns></returns>
        [HttpDelete("delete/{ids}")]
        [ActionPermissionFilter(Permission = "formula:faultsubclassdetails:delete")]
        [Log(Title = "故障信息点位详情", BusinessType = BusinessType.DELETE)]
        public IActionResult DeleteFaultSubclassDetails([FromRoute]string ids)
        {
            var idArr = Tools.SplitAndConvert<int>(ids);

            return ToResponse(_FaultSubclassDetailsService.Delete(idArr));
        }

    }
}